//
//  LGPhotoCollectionCell.m
//  RedSunDigitalDoctor
//
//  Created by 1234 on 2022/8/8.
//

#import "LGPhotoCollectionCell.h"

@implementation LGPhotoCollectionCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
//        self.contentView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:self.bigImageView];
        [self.contentView addSubview:self.photoView];
        [self.contentView addSubview:self.closeBtn];
        [self.bigImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.equalTo(self.contentView);
//            make.top.equalTo(self.contentView).offset(viewPix(10));
//            make.bottom.equalTo(self.contentView).offset(-viewPix(10));
        }];
        [self.photoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.equalTo(self.bigImageView);
        }];
        [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(-viewPix(5));
            make.right.equalTo(self.contentView).offset(viewPix(5));
            make.width.height.equalTo(@(viewPix(20)));
        }];
    }
    return self;
}

//-(void)setBigImageViewWithImage:(UIImage *)image{
//    if (_bigImageView) {
//        _BigImgView.frame = self.photoView.frame;
//        _BigImgView.image = image;
//    }
//    else{
//        _BigImgView = [[UIImageView alloc]initWithImage:img];
//        _BigImgView.frame = _profilePhoto.frame;
//        [self insertSubview:_BigImgView atIndex:0];
//    }
//    _BigImgView.contentMode = UIViewContentModeScaleToFill;
//}

-(UIImageView *)bigImageView{
    if(!_bigImageView){
        _bigImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
        _bigImageView.contentMode = UIViewContentModeScaleAspectFill;
        _bigImageView.clipsToBounds = YES;
    }
    return _bigImageView;
}

-(UIImageView *)photoView{
    if(!_photoView){
        _photoView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
        _photoView.contentMode = UIViewContentModeScaleAspectFill;
        _photoView.clipsToBounds = YES;
    }
    return _photoView;
}

-(UIButton *)closeBtn{
    if(!_closeBtn){
        _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
   
        [_closeBtn setImage:[UIImage imageNamed:@"close@3x"] forState:UIControlStateNormal];
        [_closeBtn setImage:[UIImage imageNamed:@"close@3x"] forState:UIControlStateHighlighted];
    }
    return _closeBtn;
}

@end
